package com.zhanggm.student.tests;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class JavaCollection {

    public static void main(String[] args) {
        Set<String> set1 = new HashSet<>();
        set1.add("a");
        set1.add("b");
        set1.add("c");
        Set<String> set2 = new HashSet<>();
        set2.add("d");
        set2.add("b");
        set2.add("c");

//        boolean b = set1.retainAll(set2);
//        set1.removeAll(set2)

        List<String> a = set2.stream().filter(s -> s.equals("c")).collect(Collectors.toList());
        System.out.println(a);

        System.out.println(set1);
        System.out.println(set2);

        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        Collections.sort(list, new Comparator<Object>() {
            @Override
            public int compare(Object o1, Object o2) {
                return o2.toString().compareTo(o1.toString());
            }
        });

        int sum = list.stream().mapToInt(item -> item.intValue()).sum();
        System.out.println(sum);


        System.out.println(list);

        Stream<String> a1 = Stream.of("a", "b", "c", "d");
//        System.out.println(a1.collect(Collectors.joining(",")));
//        System.out.println(a1.collect(Collectors.toList()));
        List<String> collect = a1.collect(Collectors.toList());
        System.out.println(collect);

//        a1.forEach(System.out::print);

        Stream<Object> iterate = Stream.iterate();


    }

}
